package main

import (
	"net"
	"net/rpc/jsonrpc"
	"gxgeek.com/gxgeek/learngo/lang/rpc"
	"fmt"
)

func main() {
	conn, error := net.Dial("tcp", ":1234")

	if error != nil {
		panic(error)
	}
	client := jsonrpc.NewClient(conn)
	var result float64
	err := client.Call("DemoService.Div", rpcdemo.Args{10, 2}, &result)

	if err != nil {//connection is shut down
		fmt.Println(err)
	} else {
		fmt.Println(result)
	}

	err = client.Call("DemoService.Div", rpcdemo.Args{10, 0}, &result)

	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(result)

	}

}
